//
//  ZDProfileViewController.m
//  OCSinaWeiBo
//
//  Created by Apple on 15/10/27.
//  Copyright © 2015年 itcast. All rights reserved.
//

#import "ZDProfileViewController.h"
#import <SDWebImage/SDImageCache.h>

@interface ZDProfileViewController ()

@end

@implementation ZDProfileViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"清除缓存" style:UIBarButtonItemStyleDone target:self action:@selector(clear)];
}

- (void)clear
{
    [[SDImageCache sharedImageCache] clearDisk];
    
    [self.tableView reloadData];
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 1;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
    
    CGFloat size = [[SDImageCache sharedImageCache] getSize] / 1000.0 / 1000.0;
    
    cell.textLabel.text = [NSString stringWithFormat:@"缓存%.2lf M", size];
    
    return cell;
}

@end
